<?php
/**
 * Feeds manager View
 *
 * @package		FVB_crawler
 * @subpackage	Link Manager
 * @link		http://yopensource.com
 * @author		yopensource
 * @copyright 	yopensource (yopensource@gmail.com)
 * @license		Commercial
 */

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );

jimport( 'joomla.application.component.view');

// Set the table directory
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');

/**
 * HTML View class for the Feeds manager views
 *
 * @static
 * @package		YOS
 * @subpackage	FVB_Crawler
 * @since 1.0
 */
class FVBViewContents extends JView
{
	function display($tpl = null)
	{
		global $mainframe,$option;
		
		// Set the toolbar
		$this->_setToolBar();
		
		$option			= JRequest::getCmd( 'option' );
		
		$rows			= $this->get('Data');
		$pageNav		= $this->get('Pagination');
		$lists			= $this->get('Lists');
		
		$this->assignRef('lists',	$lists);
		$this->assignRef('rows',	$rows);
		$this->assignRef('pageNav',	$pageNav);
		$this->assign('option',		$option);
		
		parent::display($tpl);
		
	}	

	function _setToolBar()
	{
		JHTML::stylesheet( 'FVB_manager.css', 'administrator/components/com_feed_manager/assets/' );		
		JToolBarHelper::title( JText::_( 'Contents Receive' ), 'url' );
		JToolBarHelper::deleteList('Are you sure?', 'content.remove', 'Delete Article(s)');
		JToolBarHelper::preferences('com_feed_manager', '300');
		JSubMenuHelper::addEntry('Feeds Manager', 'index.php?option=com_feed_manager&task=feeds', false);
		JSubMenuHelper::addEntry('Contents', 'index.php?option=com_feed_manager&task=contents', true);
		JSubMenuHelper::addEntry('Config', 'index.php?option=com_feed_manager&task=config', FALSE);
	}
	function edit()
	{
		global $mainframe;
		JHTML::stylesheet( 'fvb_manager.css', 'administrator/components/com_feed_manager/assets/' );	
		$doTask 	= JRequest::getCmd('task',null);
		$edit		=	strtolower($doTask) == 'content.edit';	
		JRequest::setVar( 'hidemainmenu', 1 );
	//	$document->addScriptDeclaration($this->get('Script'));
//		var_dump($edit);
		$row	=	$this->get('ContentEdit');
		$lists	=	$this->get('ListsEdit');
		$this->_setToolBarEdit($edit);
		$this->assignRef('row',$row);	
		$this->assignRef('lists', $lists);
		
		parent::display();
	}

	function _setToolBarEdit($edit){
		$cid = JRequest::getVar( 'cid', array(0), '', 'array' );
		$cid = intval($cid[0]);

		$text = ( $edit ? JText::_( 'Edit' ) : JText::_( 'New' ) );
		$bar =& JToolBar::getInstance('toolbar');
		JToolBarHelper::title( JText::_( 'Content Receive' ).': <small><small>[ '. $text.' ]</small></small>', 'addedit.png' );
		
		JToolBarHelper::apply('content.apply');		
		JToolBarHelper::save('content.save');
		if ( $edit ) {
			// for existing articles the button is renamed `close`
			JToolBarHelper::cancel( 'content.cancel', 'Close' );
		} else {
			JToolBarHelper::cancel('content.cancel');
		}
	}
	
}
